package com.ymatou.iapi.listpriceq.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.ymatou.iapi.productprice.service.PriceInterface;
import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.JsonBeanHelper;
import com.ymttest.utils.MapUtil;

public class GetPriceByProdIdsCall extends YmatouAutoTestCall implements PriceInterface{

	private static String opurl ="api/Price/GetPriceByProdIds";
	
	public GetPriceByProdIdsCall() {
		super(EnvSetup.getSystemUrl("listpriceq"),opurl,"POST","JSON");
	}
	
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public JSONObject callAndGetReturnData(int buyerId,List<String> productIdList){
		JSONObject requestBean = this.getJsonBean(null);
		
		JsonBeanHelper.updateJsonBean(requestBean, MapUtil.hashMap("BuyerId", buyerId,"ProductIds", new JSONArray(productIdList)));
		
		return callAndGetReturnData(requestBean);
	}
	
	
	public static void main(String[] args) {
		List<String> aList = new ArrayList<>();
		aList.add("591e1c57-fc8e-40eb-b5b5-1dade0f37009");
		new GetPriceByProdIdsCall().callAndGetReturnData(4085,aList);
	}
	
	@Override
	public JSONObject GetReturnDataByBuyerAndId(int buyerId, String id) {
		// TODO Auto-generated method stub
		return callAndGetReturnData(buyerId,Arrays.asList(id));
	}

}
